function delay(ms = 1000) {
  return new Promise(resolve => {
    setTimeout(resolve, ms)
  })
}
module.exports = app => {
  // 菜谱幻灯片接口
  app.get('/api/cookbook/swipers', (req, res) => {
    res.send({
      code: 0,
      msg: 'ok',
      data: [
        {
          id: 1,
          img: 'https://i3.meishichina.com/attachment/recipe/2023/05/10/2023051016836863586501.jpg',
          title: '第1张图片'
        },
        {
          id: 2,
          img: 'https://i3.meishichina.com/attachment/recipe/2023/05/06/2023050616833585574851.jpg',
          title: '第2张图片'
        },
        {
          id: 3,
          img: 'https://i3.meishichina.com/attachment/recipe/2018/04/24/20180424152455612584713.jpg',
          title: '第3张图片'
        }
      ]
    })
  })

  // 热门分类数据接口
  app.get('/api/cookbook/hotcate', (req, res) => {
    res.send({
      code: 0,
      msg: 'ok',
      data: [
        {
          id: 1,
          title: '家常菜'
        },
        {
          id: 2,
          title: '汤'
        },
        {
          id: 3,
          title: '川菜'
        },
        {
          id: 4,
          title: '粤菜'
        },
        {
          id: 5,
          title: '早餐'
        },
        {
          id: 6,
          title: '火锅'
        },
        {
          id: 7,
          title: '素菜'
        },
        {
          id: 8,
          title: '粥'
        },
        {
          id: 9,
          title: '凉菜'
        },
        {
          id: 10,
          title: '烘焙'
        },
        {
          id: 11,
          title: '饮品'
        }
      ]
    })
  })

  // 精品好菜接口
  app.get('/api/cookbook/goodfood', (req, res) => {
    res.send({
      code: 0,
      msg: 'ok',
      data: Array(10)
        .fill('')
        .map((item, index) => ({
          id: randomStr(),
          name: '牛肉拉面-' + index,
          img: 'https://i3.meishichina.com/attachment/recipe/2023/07/23/2023072316901164956981.jpg',
          all_click: '961.2万',
          favorites: '6.0万'
        }))
    })
  })

  // 详情页内容接口
  app.get('/api/cookbook/detail/:id', async (req, res) => {
    // await delay(9000)
    res.send({
      code: 0,
      msg: 'ok',
      data: {
        name: '牛肉炒香菜',
        img: 'https://i3.meishichina.com/attachment/recipe/2019/03/06/2019030615518497466639702111.jpg',
        code: '78599088',
        remark: '',
        all_click: '1442.2万',
        favorites: '13.0万',
        info: '宫保鸡丁的特色是辣中有甜、甜中有辣；鸡肉的鲜嫩配合花生的香脆，入口酥香、红而不辣、辣而不猛、肉质嫩滑。',
        health_str: `鸡蛋：润燥、增强免疫力、护眼明目
            姜：降逆止呕、化痰止咳、散寒解表
            料酒：活血化瘀`,
        share_img:
          'http://s3.cdn.xiangha.com/videoImg/201510/1310/561c71166b43e.jpg/MjUwX2FiYWNhaXB1MTcxMF9jXzEtM18w',
        content: `<p style="box-sizing: border-box; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255); margin-top: 0px !important;">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">1973年11月1日下午，湖北省仙桃市的一个普通家庭里出生了一对双胞胎。</span>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">哥哥五点出生，弟弟五点零五分出生，这时间成了他们命中注定的缘分。</span>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">爷爷李银生希望两个孩子以后能够成为保家卫国的英雄男儿，</span>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">给他们起名李峰华、李卫华。</span>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">他们就是后来的世界体操冠军——李大双、李小双。</span>\n</p>\n<p>\n    <img src="https://p6-tt.byteimg.com/origin/pgc-image/b2f2564a954e4209b66e5f7514a647dc?from=pc" alt="从“全能冠军”到“亿万富商”，李小双经历了什么？" class="syl-page-img"/>\n</p>\n<p class="pgc-img-caption" style="box-sizing: border-box; margin-top: 20px; padding: 0px; border: 0px; margin-bottom: 0px !important;">\n    <br/>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">李家并不富裕，父亲李裕舟是搬运工，母亲邓群姣是招待所的临时工。</span>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">虽然赚得不多，可是工作都特别耗时间，没时间照顾孩子。</span>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">没办法，母亲把兄弟两人送到了公明山外公家。</span>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">到那以后姥爷首先就给李小双改了名字，据说是一番引经据典，改名叫李政末。</span>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">两间茅草屋和农村的泥土，就是他们的乐园。</span>\n</p>\n<p style="box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; padding: 0px; border: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 18px; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255);">\n    <span style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; color: rgb(93, 93, 93); --tt-darkmode-color: #5D5D5D;">这是他们最快乐的时光，但是也养成了野马的性子。</span>\n</p>\n<p>\n    <br/>\n</p>`
      }
    })
  })
}

// 写一个随机字符串的方法
function randomStr() {
  return Math.random().toString(36).slice(2)
}
